package com.app.community.mapper;

import com.app.community.model.entity.User;
import org.apache.ibatis.annotations.*;

/**
 * 2020/10/21 14:01
 **/
@Mapper
public interface HomeMapper {

    @Results({
            @Result(column = "user_id",property = "userId"),
            @Result(column = "nick_name",property = "nickName"),
            @Result(column = "cover_pic",property = "coverPic")
    })
    @Select({"select nick_name,introduction,avatar,cover_pic,sex,subject,year from user where user_id = #{userId}"})
    User searchUserInfo(@Param("userId") String userId);


    /**
     * 更新用户信息
     */
    @Update({"update user set sex = #{sex} where user_id = #{userId}"})
    void updateUserSex(@Param("sex")String sex,@Param("userId")String userId);

    /**
     * 更新用户信息
     */
    @Update({"update user set nick_name = #{nickName} where user_id = #{userId}"})
    void updateUserNickname(@Param("nickName")String nickName,@Param("userId")String userId);

    /**
     * 更新用户信息
     */
    @Update({"update user set introduction = #{introduction} where user_id = #{userId}"})
    void updateUserIntro(@Param("introduction")String introduction,@Param("userId")String userId);

    /**
     * 更新用户信息
     */
    @Update({"update user set subject = #{subject} where user_id = #{userId}"})
    void updateUserSubject(@Param("subject")String subject,@Param("userId")String userId);

    /**
     * 更新用户信息
     */
    @Update({"update user set year = #{year} where user_id = #{userId}"})
    void updateUserYear(@Param("year")String year,@Param("userId")String userId);


    /**
     * 更新头像
     */
    @Update({"update user set avatar = #{avatar} where user_id = #{userId}"})
    void updateUserAvatar(@Param("avatar")String avatar,@Param("userId")String userId);

    /**
     * 更新背景
     */
    @Update({"update user set cover_pic = #{coverPic} where user_id = #{userId}"})
    void updateUserCoverPic(@Param("coverPic")String coverPic,@Param("userId")String userId);
}
